<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>父组件向子组件传递数据</title>
    <script src="vue.js"></script>
  </head>
  <body>
    <div id="app">
      <parent></parent>
    </div>
    <script>
      var childNode = Vue.extend({
        template: "<div><p>这是子组件</p> {{ pdata }}</div>",
        props: ["pdata"],
      });
      var parentNode = Vue.extend({
        template: "<div>这是父组件<child :pdata=msg></child></div>",
        data() {
          return {
            msg: "这是父组件传给子组件的数据:123",
          };
        },
        components: {
          child: childNode,
        },
      });
      // 创建根实例
      var vm = new Vue({
        el: "#app",
        components: {
          parent: parentNode,
        },
      });
    </script>
  </body>
</html>
